//
//  EFAMsgCtrlRecTCell.m
//  efairy
//
//  Created by XiangDongMBP on 2017/7/12.
//  Copyright © 2017年 East. All rights reserved.
//

#import "EFAMsgCtrlRecTCell.h"
#import "EFAModel.h"

@implementation EFAMsgCtrlRecTCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.portraitImgView.userInteractionEnabled = YES;
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(portraitGestureTapped:)];
    [self.portraitImgView addGestureRecognizer:tapGesture];
    
    [self.alarmBtn addTarget:self action:@selector(alarmBtnTapped:) forControlEvents:UIControlEventTouchUpInside];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)portraitGestureTapped:(UITapGestureRecognizer *)gesture {
    if ([self.delegate respondsToSelector:@selector(msgCtrlRecvTCell:portraitTapped:)]) {
        [self.delegate msgCtrlRecvTCell:self portraitTapped:gesture];
    }
}
- (void)alarmBtnTapped:(UIButton *)btn {
    if ([self.delegate respondsToSelector:@selector(msgCtrlRecvTCell:alarmBtnTapped:)]) {
        [self.delegate msgCtrlRecvTCell:self alarmBtnTapped:btn];
    }
}
- (void)configViewWithIMItem:(EFAMsgIMItem *)item {
    self.timeLabel.text = item.efairymsg_add_time;
    if(item.efairymsg_content && item.efairymsg_content.length > 0){
        self.msgLabel.text = item.efairymsg_content;
    }else{
        self.msgLabel.text = item.efairydevicemsg_content;
    }
   
    self.alarmBtn.hidden = !item.efairydevicemsg_msgtype;
    self.alarmBtn.selected = item.efairydevicemsg_ishandle;
//    [self setSelected:item.isSelected animated:NO];
}

@end
